package com.tao.gulimall.ware.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@MapperScan("com.tao.gulimall.ware.dao")
@EnableTransactionManagement
public class WareMyBatisConfig {
	/**
	 * 添加分页插件
	 */
	@Bean
	public MybatisPlusInterceptor mybatisPlusInterceptor() {
		MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
		PaginationInnerInterceptor pi = new PaginationInnerInterceptor(DbType.MYSQL);
		pi.setOverflow(false);
		pi.setMaxLimit(500L);
		// 如果配置多个插件, 切记分页最后添加
		interceptor.addInnerInterceptor(pi);
		// 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType

		return interceptor;
	}
}
